﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using BPM.Entity;

namespace BPM.Service.Mappings
{
	internal class MaterialDefinitionConfiguration : EntityConfiguration<MaterialDefinition>
	{
		public MaterialDefinitionConfiguration()
		{
			this.HasRequired(m => m.Category)
				.WithMany()
				.HasConstraint((m, c) => m.CategoryId == c.Id)
				.WillCascadeOnDelete(false);

			this.HasRequired(m => m.Barcode)
				.WithMany()
				.HasConstraint((m, b) => m.BarcodeId == b.Id)
				.WillCascadeOnDelete(false);

			this.HasRequired(m => m.Creator)
				.WithMany()
				.HasConstraint((m, u) => m.CreatorId == u.Id)
				.WillCascadeOnDelete(false);
		}
	}
}